﻿using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;

namespace Metro.Kashikoi.ServiceContract.Storage
{
    /// <summary>
    /// This class defines the door trigger.
    /// </summary>
    [DataContract(IsReference = true)]
    [Table("DoorTriggers")]
    public class DoorTrigger : Trigger
    {
        /// <summary>
        /// Gets or sets the flip target.
        /// </summary>
        /// <value>
        /// The flip.
        /// </value>
        [DataMember]
        [Range(1, int.MaxValue)]
        [RangeValidator(1, RangeBoundaryType.Inclusive, int.MaxValue, RangeBoundaryType.Inclusive)]
        public int Flip { get; set; }

        /// <summary>
        /// Copies the specified to the destination.
        /// </summary>
        /// <param name="destination">The destination.</param>
        public void CopyTo(DoorTrigger destination)
        {
            destination.Flip = this.Flip;
        }

        /// <summary>
        /// Clones this instance.
        /// </summary>
        /// <returns>
        /// Newly cloned instance.
        /// </returns>
        public override Trigger Clone()
        {
            var trigger = new DoorTrigger();
            this.CopyTo(trigger);
            return trigger;
        }
    }
}
